package base.file.api;

import java.io.File;

public class FileFieldSummary {
    public static void main(String[] args) {
        separatorDemo();

        pathDemo();
    }

    public static final void separatorDemo() {
        // 系统相关的默认名称分隔符 如 : win系统为 "\"
        System.out.println(File.separator);
        System.out.println(File.separatorChar);

        // 系统相关的路径分隔符 如: win系统为 ";"
        System.out.println(File.pathSeparator);
        System.out.println(File.pathSeparatorChar);
    }

    public static final void pathDemo() {
        String path = "C:\\Temp\\test\\infinity-wallpaper.jpg";
        System.out.println(File.separator);

        // 建议
        // 1. /
        path = "C:/Temp/test/infinity-wallpaper.jpg";
        System.out.println(path);

        //  2. 常量拼接
        path = "c:" + File.separator + "Temp" + File.separator + "test" + File.separator + "infinity-wallpaper.jpg";
        System.out.println(path);
    }
}
